package com.android.delivery.receiver;

import com.android.delivery.util.print.ListUtils;

import java.util.HashSet;
import java.util.Set;

public class PushNotifyManager {

    private static PushNotifyManager mInstance;

    private Set<PushDispatchListener> mPushDispatchListeners;

    public static PushNotifyManager getInstance() {
        if (mInstance == null){
            mInstance = new PushNotifyManager();
        }
        return mInstance;
    }

    public PushNotifyManager() {
        if (mPushDispatchListeners == null){
            mPushDispatchListeners = new HashSet<>();
        }
    }

    public void dispatchOrderRece(){
        if (mPushDispatchListeners != null){
            for (PushDispatchListener listener: mPushDispatchListeners) {
                listener.onReceOrder();
            }
        }
    }

    public void addPushDispatchListener(PushDispatchListener listener){
        if (!mPushDispatchListeners.contains(listener)){
            mPushDispatchListeners.add(listener);
        }
    }

    public void removePushDispatchListener(PushDispatchListener listener){
        if (mPushDispatchListeners.contains(listener)){
            mPushDispatchListeners.remove(listener);
        }
    }
}
